<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">

        <ui:define name="content">

            <h:form>
                <p:panel toggleable="true" id="customerEdit" header="Edit Customer Details">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_companyName}" for="companyName" />
                        <p:inputText id="companyName" value="#{customerEntityController.selected.companyName}" title="#{bundle.EditCustomerEntityTitle_companyName}" required ="true" requiredMessage="Company name is missing"/>
                        <h:message styleClass="errorMsg" for= "companyName"/>

                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_jobTitle}" for="jobTitle" />
                        <p:inputText id="jobTitle" value="#{customerEntityController.selected.jobTitle}" title="#{bundle.EditCustomerEntityTitle_jobTitle}" required="true" requiredMessage="Job title is missing"  />
                        <h:message styleClass="errorMsg" for= "jobTitle"/>


                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_customerExecutive}" for="customerExecutive" />
                        <h:selectOneMenu id="customerExecutive" value="#{customerEntityController.selected.customerExecutive}" title="#{bundle.EditCustomerEntityTitle_customerExecutive}" >
                            <f:selectItems value="#{systemUserEntityController.salesExecutiveAvailableSelectOne}"/>
                            <f:validator validatorId="macTeam.SystemUserSelectOneMenuValidator" />
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for="customerExecutive"/>


                        <h:outputLabel value="UserName" for="name" />
                        <p:inputText disabled="true" id="name" value="#{customerEntityController.selected.name}" title="#{bundle.EditCustomerEntityTitle_name}" required="true" requiredMessage="UserName is missing" 
                                     validator ="#{systemUserEntityController.validateUserName}" />
                        <h:message styleClass="errorMsg" for= "name"/>

                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_firstName}" for="firstName" />
                        <p:inputText id="firstName" value="#{customerEntityController.selected.firstName}" title="#{bundle.EditCustomerEntityTitle_firstName}" required="true" requiredMessage="First name is missing" />
                        <h:message styleClass="errorMsg" for= "firstName"/>

                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_lastName}" for="lastName" />
                        <p:inputText id="lastName" value="#{customerEntityController.selected.lastName}" title="#{bundle.EditCustomerEntityTitle_lastName}" required="true" requiredMessage="Last name is missing" />
                        <h:message styleClass="errorMsg" for= "lastName"/>

                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_title}" for="title" />
                        <h:selectOneMenu id="title" value="#{customerEntityController.selected.title}" title="#{bundle.EditCustomerEntityTitle_title}" >
                            <f:selectItems value="#{systemUserEntityController.userTitles}"/>
                        </h:selectOneMenu>                    
                        <h:message styleClass="errorMsg" for= "title"/>

                        <h:outputLabel value="Customer Type: " for="customerType" />
                        <h:selectOneMenu id="customerType" value="#{customerEntityController.selected.customerType}" title="customerType" >
                            <f:selectItems value="#{customerEntityController.customerType}"/>
                        </h:selectOneMenu>                    
                        <h:message styleClass="errorMsg" for= "customerType"/>

                        <h:outputLabel value="#{bundle.EditCustomerEntityLabel_contactNumber}" for="contactNumber" />
                        <p:inputText id="contactNumber" value="#{customerEntityController.selected.contact.contactNumber}" >
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "ContactNumber" />

                        <h:outputLabel value="#{bundle.EditSalesLeadEntityLabel_email}" for="email" />
                        <p:inputText  id="email" value="#{customerEntityController.selected.contact.email}">
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "email" />


                    </h:panelGrid>
                </p:panel>
                <br />
                <ui:include src="/entities/addressEntity/EditAddress.xhtml"/>
                <br />
                <p:commandButton ajax="false" action="#{customerEntityController.update}" value="#{bundle.EditCustomerEntitySaveLink}"/>
                <p:commandButton ajax="false" action="View" value="#{bundle.EditCustomerEntityViewLink}" rendered="#{loginBacking.viewAllCustomer}" immediate="true"/>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
